PREFIX ?= /usr/local
BINDIR = $(DESTDIR)$(PREFIX)/bin
DOCDIR = $(DESTDIR)$(PREFIX)/share/doc/mkblog.sh
BLOGDIR = 'blog'

.PHONY: all build init install page post uninstall

all:

build:
	./mkblog.sh build $(BLOGDIR)

init:
	./mkblog.sh init $(BLOGDIR)

install:
	install -m755 -d $(BINDIR)
	install -m755 -d $(DOCDIR)
	install -m755 .mkblog.sh $(BINDIR)
	install -m644 README.md $(DOCDIR)
	install -m755 mkblog.sh $(BINDIR)/mkblog
	sed -i 's|./\(.mkblog.sh\)|$(BINDIR)/\1|' $(BINDIR)/mkblog

page:
	./mkblog.sh new page $(BLOGDIR)

post:
	./mkblog.sh new post $(BLOGDIR)

uninstall:
	rm -f $(BINDIR)/.mkblog.sh
	rm -f $(BINDIR)/mkblog
	rm -fr $(DOCDIR)
